<template>
	<view class="feedback">
		<uv-navbar placeholder title="反馈中心" @leftClick="leftClick"></uv-navbar>
		<view class="block">
			<view class="block-title">
				反馈内容/意见
			</view>
			<view class="textareaBox">
				<textarea class="textarea" v-model="formLine.content" placeholder-class="styles" maxlength="300" placeholder="请输入"></textarea>
				<text class="conut">{{formLine.content.length}}/300</text>
			</view>
		</view>
		<view class="block">
			<view class="block-title">图片（选填，提供问题截图）({{formLine.images.length}}/9)</view>
			<view class="imgs">
				<UploadImgs keyName="images" @getUrl="getUrl" />
			</view>
		</view>
		<view class="footer">
			<view class="btn" @click="onSave">保存</view>
		</view>
	</view>
</template>

<script>
	import reqApi from "../../api/api.js";
	export default {
		data() {
			return {
				formLine: {
					images: [],
					content: ""
				},
			}
		},
		methods: {
			onSave(){
			   reqApi.feedbackAdd(this.formLine).then(res=>{
				   uni.showToast({
				     title: "提交成功",
				     duration: 1500,
				     icon: 'none',
				     mask: true
				   })
				   setTimeout(()=>{
					   uni.redirectTo({
					   	url: "/pages/mine/feedbackList"
					   })
				   }, 1500)
			   })
			},
			getUrl(e) {
				console.log("子组件传过来的", e);
				const {
					keyName,
					arr
				} = e;
				this.formLine[keyName] = arr;
			},
			leftClick() {
				uni.switchTab({
					url: "/pages/mine/feedbackList"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.footer {
		padding: 0 40rpx;
		box-sizing: border-box;
		position: fixed;
		bottom: 30rpx;
		width: 100%;
		.btn {
			width: 100%;
			height: 88rpx;
			background: #EEA800;
			border-radius: 88rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
		}
	}
	.feedback {
		width: 100vw;
		height: 100vh;
		background: #fff;

		.block {
			padding: 0 30rpx;
			box-sizing: border-box;
			.block-title {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #232323;
				padding: 30rpx 0;
				box-sizing: border-box;
			}

			.textareaBox {
				width: 100%;
				background: #F7F7F7;
				border-radius: 16rpx;
				padding: 20rpx;
				box-sizing: border-box;
				height: 260rpx;

				.styles {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #AAAAAA;
				}

				.textarea {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #222;
					height: 200rpx;
					width: 100%;
				}

				.conut {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #AAAAAA;
					display: flex;
					justify-content: flex-end;
				}
			}
		}
	}
</style>
